package com.ruoyi.web.api.controller.system;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.District;
import com.ruoyi.system.service.IDistrictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 行政区划信息操作处理
 *
 * @author ruoyi
 */
@Api(tags = "行政区划管理")
@RestController
@RequestMapping("/system/district")
public class DistrictController extends BaseController {

    private final IDistrictService districtService;

    public DistrictController(IDistrictService districtService) {
        this.districtService = districtService;
    }


    /**
     * 获取行政区划列表
     */
    @ApiOperation(value = "获取行政区划列表", notes = "获取所有行政区划信息")
    @GetMapping("/list")
    public AjaxResult list(District district) {
        List<District> districts = districtService.selectDistrictList(district);
        return success(districts);
    }

    /**
     * 根据行政区划编号获取详细信息
     */
    @ApiOperation(value = "获取行政区划详细信息", notes = "根据id获取行政区划详细信息")
    @ApiImplicitParam(name = "id", value = "行政区划ID", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable Long id) {
        return success(districtService.selectDistrictById(id));
    }

}